// 简单的 defineProperty polyfill
if (!Object.defineProperty) {
  Object.defineProperty = function(obj, prop, descriptor) {
    if (descriptor.get) {
      obj.__defineGetter__(prop, descriptor.get);
    }
    if (descriptor.set) {
      obj.__defineSetter__(prop, descriptor.set);
    }
    if (descriptor.value) {
      obj[prop] = descriptor.value;
    }
    return obj;
  };
}

// 导出一个空的 defineProperty 函数，用于兼容 babel runtime
function defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }
  return obj;
}

module.exports = defineProperty;
